<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>登录页展示-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<style>
	#modal-delete.opacity{ opacity: 1; z-index: 1052; background: rgba(0,0,0,0.5); }
</style>
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">登录页展示</div>
		<!--<div class="right">
			<if condition="is_permission('ZS',NULL,1)">
				<a href="javascript:;" class="btn btn-add">新增员工风采展示</a>
			</if>
		</div>-->
	</div>
	<div id="content">
		<div class="table-scrollx">
			<table class="table table-bordered table-hover">
				<tr class="table-header fixed-table-header">
					<td width="120">
						<select name="username" class="form-control" style="width:85px;">
							<option value="-10"<if condition="$username eq -10"> selected</if>>姓名</option>
							<foreach name="result1" item="vo">
							<option value="{$vo['id']}"<if condition="$username eq $vo['id']"> selected</if>><if condition="$vo['username1'] neq NULL">{$vo['username1']}<else/>{$vo['username']}</if></option>
							</foreach>
						</select>
					</td>
					<td width="">展示</td>
					<td width="">职位</td>
					<td width="">是否有照片</td>
					<td width="">日期</td>
					<if condition="is_permission('ZS',NULL,1)">
					<td width="">管理</td>
					</if>
				</tr>
				<if condition="$result eq NULL">
				<tr>
					<td <if condition="is_permission('ZS',NULL,1)">colspan="5"<else/>colspan="4"</if> class="text-center">暂无相关内容</td>
				</tr>
				</if>
				<foreach name="result" item="vo">
				<tr>
					<td>{$vo['name']}</td>
					<td>{$vo['hello_img']}</td>
					<td>{$vo['content']}</td>
					<td><if condition="$vo['img'] eq NULL"><span class="red">无</span><else/>有</if></td>
					<td>{$vo['remark']|substr=0,10}</td>
					<if condition="is_permission('ZS',NULL,1)">
					<td>
						<a href="javascript:;" data-toggle="tooltip" data-placement="left" title="" class="edit mr5" data-original-title="编辑" hello_img="{$vo['hello_img']}" contents="{$vo['content']}" remark="{$vo['remark']|substr=0,10}" mid="{$vo['id']}" names="{$vo['name']}"><i class="glyphicon glyphicon-edit"></i></a>
					</td>
					</if>
				</tr>
				</foreach>
			</table>
		</div>
		<div class="pages">{$page}</div>
	</div>
</div>
<!--编辑弹框-->
<div class="modal fade" id="edit-modal">
	<div class="modal-dialog w600">
		<div class="modal-content">
			<div class="modal-header">
				<h4></h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body" style="line-height:30px;">
				<table class="table table-bordered">
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>展示</strong></td>
						<td>
							<textarea name="hello_img" class="form-control w400" autocomplete="off"></textarea><span class="error-item">必填项</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>职位</strong></td>
						<td>
							<textarea name="content" class="form-control w400" autocomplete="off"></textarea><span class="error-item">必填项</span>
						</td>
					</tr>
					<tr class="set_time">
						<td class="text-right"><strong><span class="asterisk">*</span>日期</strong></td>
						<td>
							<input type="text" class="form-control Wdate w100 date" onclick="WdatePicker()" readonly autocomplete="off" />
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong>附件</strong></td>
						<td>
							<div class="input-group w300 left">
						    	<input type="text" class="form-control file-name" placeholder="请上传员工照片" autocomplete="off">
					    		<span class="input-group-btn">
					        		<button class="btn file-submit" type="button">上传</button>
						    	</span>
						    </div>
						    <input type="hidden" class="file-url" autocomplete="off">
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-affirm">确认</button><button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<!--确认弹框-->
<div class="modal fade" id="modal-delete" >
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h4>确认提示框</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">该日期与<span></span>的日期有冲突，确定要提交吗</div>
			<div class="modal-footer">
				<button type="button" class="btn delete-confirm">确认</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>

<include file="Include:javascript" />
<script type="text/javascript">
$(function(){
	$('.btn-default,.fa-times').click(function(){
		$('#modal-delete').fadeOut().removeClass('opacity');
	});
	$('.delete-confirm').click(function(){
		var tag = true,
			mid = $(this).attr('mid'),
			txt = $(this).attr('txt'),
			cont = $(this).attr('cont'),
			time = $(this).attr('time');
		$.ajax({
			type:"POST",
			async:false,
			dataType:"json",
			data:{"id":mid,"hello_img":txt,"content":cont,"remark":time,"action":'edit'},
			url:"__APP__/Administration/login_show_ajax",
			success:function(data){
				$('#edit-modal,#modal-delete').hide().removeClass('opacity');
				success_pop(data.status,data.msg);
			}
		})
	});
	KindEditor.ready(function(K){
		//上传附件
		var editorFile = K.editor();
		$('.file-submit').on('click',function(){
			var parents = $(this).parents(".input-group");
			editorFile.loadPlugin('insertfile',function(){
				document.cookie="file_name=login";
				document.cookie="file_type=jpg,jpeg,png";
				editorFile.plugin.fileDialog({
					clickFn:function(url,title){
						parents.nextAll(".error-item").hide();
						parents.find(".file-name").val(title).prop("readonly",false);
						parents.nextAll(".file-url").val(url);
						editorFile.hideDialog();
					}
				});
			});
		});
	});
	//表头选择
	$(document).on("change","[name='username']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Administration/login_show/username/"+val;
	});
	//编辑员工风采
	$('.edit').click(function(){
		
		var mid = $(this).attr('mid'),
			txt = $(this).attr('hello_img'),
			reg1 = new RegExp("<br/>", "g"),
			str1 = txt.replace(reg1, "\n"),
			name = $(this).attr('names'),
			content = $(this).attr('contents'),
			reg2 = new RegExp("<br/>", "g"),
			str2 = content.replace(reg2, "\n"),
			time = $(this).attr('remark'),
			modal = $('#edit-modal');
		modal.find(".file-name").prop("readonly",true);
		modal.find('.error-item').hide();
		modal.modal();
		modal.find('h4').html(name);
		modal.find("[name='hello_img']").val(str1);
		modal.find("[name='content']").val(str2);
		modal.find(".date").val(time);
		modal.find('.btn-affirm').attr('mid',mid)
	})
	$('.btn-affirm').click(function(){
		var tag = true,
			mid = $(this).attr('mid'),
			txt = $("[name='hello_img']").val(),
			reg1 = new RegExp("\n", "g"),
    		str1 = txt.replace(reg1, "<br/>"),
			cont = $("[name='content']").val(),
			reg2 = new RegExp("\n", "g"),
    		str2 = cont.replace(reg2, "<br/>"),
			file_url = $(".file-url").val(),
			file_name = $(".file-name").val(),
			time = $('.date').val();

			
		$('.delete-confirm').attr('mid',mid);
		$('.delete-confirm').attr('txt',str1);
		$('.delete-confirm').attr('cont',str2);
		$('.delete-confirm').attr('time',time);
		if(txt ==''){
			tag = false;
			$("[name='hello_img']").next('.error-item').show();
		}
		if(cont ==''){
			tag = false;
			$("[name='content']").next('.error-item').show();
		}
		if(tag){
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:{"id":mid,"hello_img":str1,"content":str2,"remark":time,"action":'query'},
				url:"__APP__/Administration/login_show_ajax",
				success:function(data){
					if(data.type==1){
						$.ajax({
							type:"POST",
							async:false,
							dataType:"json",
							data:{"id":mid,"hello_img":str1,"content":str2,"remark":time,"img":file_url,"file_name":file_name,"action":'edit'},
							url:"__APP__/Administration/login_show_ajax",
							success:function(data){
								$('#edit-modal').hide();
								success_pop(data.status,data.msg);
							}
						});
					}else if(data.type==-1){
						$('#modal-delete').fadeIn().addClass('opacity');
						$('#modal-delete .modal-body span').html(""+data.name+"");
					}
				}
			});
		}
	})

	$('textarea').blur(function(){
		$(this).next('.error-item').hide();
	})
});
</script>
</body>
</html>